package OOP;

public class InnerClass {
    private String name = "shell";
    private static int id = 233;

    public class Member {
        public void getOuter() {
            System.out.println("[Outer] id = " + id + ", name = " + name);
        }
    }

    public static class Embed {
        public void getOuter() {
            System.out.println("[Outer] id = " + id + ", name = " + new InnerClass().name);
        }
    }

    public void domain() {
        class Local {
            public void getOuter() {
                System.out.println("[Outer] id = " + id + ", name = " + name);
            }
        }
        Local l = new Local();
        l.getOuter();
    }

    public Inner createInner(final String name) {
        return new Inner() {
            private String nameStr = name;

            public String getName() {
                return nameStr;
            }
        };
    }

    public static void main(String[] args) {
        InnerClass e = new InnerClass();
        Member m = e.new Member();
        m.getOuter();
        Embed b = new Embed();
        b.getOuter();
        e.domain();
        System.out.println(e.createInner("inner").getName());
    }
}

interface Inner {
    String getName();
}
